package com.androwit.engine.mapping;

import java.util.Map;

/**
 * Works as a factory to create instances of java beans {@link #createInstance(Map)}, and analyzes content to establish the mapping fields to be 'serialized
 * to/read from' an object
 * 
 * @param <K>
 *          the key type
 * @param <V>
 *          the persistence side value type
 * 
 * @author Zied Hamdi Founder of http://1vu.fr
 * 
 */
public interface MappingFieldsDefiner<J, K, V> {
	/**
	 * returns the mapped fields definitions with converters
	 * 
	 * @param serializable
	 * @return
	 */
	public MappingField<J, K, V>[] getMappedFields(Map<K, V> values);

	/**
	 * Analyses content and returns an empty corresponding instance to hold that data
	 * 
	 * @param values
	 * @return
	 */
	public Object createInstance(Map<K, V> values);

	/**
	 * returns the {@link MappingField}s for the current java instance (to write it to its String form)
	 * 
	 * @param toPersist
	 *          the current instance to persist
	 * @return the columns definitions to persist for <code>toPersist</code>
	 */
	public MappingField<J, K, V>[] getMappingFields(Object toPersist);

}
